from transformers import AutoModelForCausalLM,AutoTokenizer
#加载微调好的模型
final_save_path = "./final_saved_path"
model = AutoModelForCausalLM.from_pretrained(final_save_path)
tokenizer = AutoTokenizer.from_pretrained(final_save_path)
# 构建推理的pipeline

from transformers import  pipeline
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
prompt="地球离太阳的距离是多少公里"
generated_text = pipe(prompt, max_length=512, num_return_sequences=1)

# print("开始问答：-----",generated_text[0]["generated_text"])
